
game:setAmbient(0.9,0.9,0.9)

game:createTargetControlLogic("DoNothingControlLogic",{maxForce=0, maxTorque=0},function(_)
end)

--Hangar
game:createNode({x=0.0, y=0.0, z=0.0},{x=0.0, y=180.0, z=0.0},{x=1, y=1, z=1},function(node,controlnode)
		game:PhysicsEntity("Hangar",node,controlnode,{mesh="Hangar.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="SimpleBox"},function(_)
		end)
end)

game:createNode({x=5000.0, y=0, z=0},{x=0.0, y=0.0, z=0.0},{x=5, y=5, z=5},function(node,controlnode)
		game:PhysicsEntity("GoalSinbad",node,controlnode,{mesh="sinbad.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=300000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="SimpleBox"},function(_)
		end)
end)


--game:createNode({x=0.0, y=0.0, z=0.0},{x=0.0, y=0.0, z=0.0},{x=4.0, y=4.0, z=4.0},function(node,controlnode)
--		game:PhysicsEntity("kard",node,controlnode,{mesh="Derins_Sword.mesh", controlLogic="PlayerControlLogic",collisionGroup=1, weight=300.0, boundingBox=3.95, isStatic=false, isKinematic=true, actorDesc="SimpleBox"},function(_)
--			game:addTrigger(_,function(_)
--				game:DamageAction(_,{damage=20})
--				game:PositionReq(_,{x=0,y=200,z=0, radius=20})
--			end)
--		end)
--end)


-- Map, the base points of the curve path
Map = {
	numberOfPoints = 7,

	point1={x=-400,y=0,z=0},
	point2={x=0,y=0,z=0},
	point3={x=1000,y=0,z=0},
	point4={x=2000,y=0,z=0},
	point5={x=3000,y=0,z=0},
	point6={x=4000,y=0,z=0},
	point7={x=5000,y=0,z=0},


	--point4={x=2000,y=100,z=200},
	--point5={x=5000,y=1000,z=400},
	--point6={x=8000,y=200,z=-200},
	--point7={x=11000,y=1500,z=0},
	--point8={x=14000,y=500,z=200},
	point9={x=17000,y=1000,z=600},
	point10={x=20000,y=200,z=-200},

	point11={x=23000,y=1500,z=0},
	point12={x=26000,y=500,z=300},
	point13={x=29000,y=1000,z=400},
	point14={x=31000,y=200,z=-300},
	point15={x=34000,y=1500,z=0},
	point16={x=37000,y=500,z=200},
	point17={x=40000,y=1000,z=400},
	point18={x=43000,y=200,z=-200},
	point19={x=45000,y=1500,z=0},
	point20={x=45500,y=500,z=200}
}

-- BodyRailControlLogic
game:createBodyRailControlLogic("BodyRailControlLogic", {mapBasePoints = Map, resolution = 0.06} )

-- Map element types
MapElements = {
	BaseElements = {
		numBases = 4,
		element1 = {mesh="Meteor1.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=30.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element2 = {mesh="Meteor2.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=30.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element3 = {mesh="Meteor3.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=30.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element4 = {mesh="Meteor4.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=30.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"}
	},
	SpecElements = {
		numSpecs = 12,
		element1 = {mesh="MetalTriangleGrid_small.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element2 = {mesh="OrangeRocket.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element3 = {mesh="OrangeRocket01.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element4 = {mesh="OrangeRocket02.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element5 = {mesh="OrangeRocket03.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element6 = {mesh="OrangeRocket04.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element7 = {mesh="OrangeRocket05.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element8 = {mesh="Parabola.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element9 = {mesh="Satelit.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element10 = {mesh="Satelit01.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element11 = {mesh="Satelit02.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"},
		element12 = {mesh="Satelit03.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="_boundingBox"}
	},
	func = function(_) end
}

-- Generate the Map objects around the map base points
game:createMap("purple_nebula_skybox", {mapBasePoints = Map, resolution = 0.2, percent = 80.0, elementTypes = MapElements, maxElements = 15})


--game:createNode({x=0.0, y=0.0, z=-100.0},{x=0.0, y=0.0, z=0.0},{x=1.0, y=1.0, z=1.0},function(node,controlnode)
--	game:PhysicsEntity("body",node,controlnode,{mesh="Derins_Sword.mesh", controlLogic="BodyRailControlLogic",collisionGroup=1, weight=300.0,boundingBox=0.1, isStatic=false, isKinematic=true, actorDesc="SimpleBox"},function(_)
--	end)
--	game:createCamera(node,{name="mainCam"})
--	game:addNode(node,controlnode,{x=0.0, y=0.0, z=0.0},{x=0.0, y=0.0, z=0.0},{x=2.0, y=2.0, z=2.0},function(node,controlnode)
--		game:PhysicsEntity("kard",node,controlnode,{mesh="ZealotInfected.mesh", controlLogic="PlayerControlLogic",collisionGroup=1, weight=300.0, boundingBox=3.95, isStatic=false, isKinematic=true, actorDesc="Sword"},function(_)
--		end)
--	end)
--end)


game:createTargetControlLogic("TargetLauncher",{maxForce=5000, maxTorque=0.01},function(_)
	game:Launcher(_,{mesh="MeatBall.mesh",position={x=0,y=20,z=0},velocity={x=3000000,y=3000000,z=3000000},cooldown=0.1})
end)


game:createNode({x=0.0, y=0.0, z=-100.0},{x=0.0, y=0.0, z=0.0},{x=1.0, y=1.0, z=1.0},function(node,controlnode)
	game:createCamera(node,{name="mainCam"})

	game:Entity("kard",node,controlnode,{controlLogic="AIControlLogic"},function(entity)
			game:PhysicsBody(entity,node, {collisionGroup=1, weight=300.0, boundingBox=3.95, isStatic=false, isKinematic=true,disableGravity=true, actorDesc="Sword"},function(body)end) 
			game:OgreBody(entity,node, {mesh="ZealotInfected.mesh"}, function(body)
				game:setMasterBody(entity,body)
			end)
			game:addController(entity,"TargetLauncher") 
			game:addTrigger(entity,function(_)
				game:PositionReq(_,{x=5000,y=0,z=0 ,radius=100})
				game:CustomScriptAction(_,function()
					game:setWindowVisible("GameOverWindow",true)
					game:setCursorVisible(true)
				end)
			end)
	end)

		




	
end)



-- Some planets
game:createNode({x=130000.0, y=0.0, z=-20000.0},{x=0.0, y=0.0, z=0.0},{x=250, y=250, z=250},function(node,controlnode)
		game:PhysicsEntity("PlanetGasGiant01",node,controlnode,{mesh="PlanetGasGiant01.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="SimpleBox"},function(_)
		end)
end)
game:createNode({x=70000.0, y=600.0, z=40000.0},{x=0.0, y=0.0, z=0.0},{x=400, y=400, z=400},function(node,controlnode)
		game:PhysicsEntity("PlanetOceanic02",node,controlnode,{mesh="PlanetOceanic02.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="SimpleBox"},function(_)
		end)
end)
game:createNode({x=35000.0, y=-2000.0, z=-20000.0},{x=0.0, y=0.0, z=0.0},{x=250, y=250, z=250},function(node,controlnode)
		game:PhysicsEntity("PlanetVolcanic03",node,controlnode,{mesh="PlanetVolcanic03.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="SimpleBox"},function(_)
		end)
end)

game:createNode({x=200000.0, y=60000.0, z=50000.0},{x=0.0, y=0.0, z=0.0},{x=250, y=250, z=250},function(node,controlnode)
		game:PhysicsEntity("PlanetJungle01",node,controlnode,{mesh="PlanetJungle01.mesh", controlLogic="DoNothingControlLogic",collisionGroup=5, weight=3000000000.0, boundingBox=1.0, isStatic=false, isKinematic=true, actorDesc="SimpleBox"},function(_)
		end)
end)
